home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / delay.arc / DELAY.ASM next >
Encoding:
Assembly Source File  |  1985-12-04  |  5.4 KB  |  166 lines

  1. ; delay.asm --> a program to slow the computer down.  especially nice if you
  2. ;        have an IBM AT or compatible or an IBM AT that is running
  3. ;        faster than the normal 6 megahertz.  this program was written
  4. ;        specifically for playing games on an AT at a normal playing
  5. ;        speed relative to the IBM PC.  however, there may be other uses
  6. ;        yet unknown to me.  to change the amount of delay, change the
  7. ;        value after the equ in delay_count.  a value of 55h slows my
  8. ;        8 megahertz at to slightly faster than IBM PC as reported by
  9. ;        Peter Norton's utility SI (system information).  the value
  10. ;        reported is 1.1 relative to an IBM PC.  of course, there may
  11. ;        game programs that automatically compensate for the increased
  12. ;        speed of an AT and this program would then be useless.  for
  13. ;        example, sublogic's jet simulator (it looks fantastic at 8
  14. ;        megahertz).  however, other games such as digdug, zaxxon, and
  15. ;        startrek, just to name a few are a lot easier to play with the
  16. ;        delay than at 8 megahertz (it's like driving down the highway
  17. ;        at 450 mph.)
  18. ;
  19. ;        Note:  this program uses the timer interrupt and speeds up the
  20. ;               number of interrupts from 18.2 to 256 per second.
  21. ;               however, this speedup is offset so that the clock ticks
  22. ;               properly.
  23. ;
  24. ;        Marvin E. Wilborne III
  25. ;        Route 5 Box 314
  26. ;        Danville, Va.  24540
  27. ;
  28. ;        Copyright (c) 1985, All rights reserved, Worldwide.
  29. ;        This program may be copied, and distributed for free in its
  30. ;        original unmodified form only.  This notice cannot be deleted.
  31.  
  32. delay_count    equ    55h            ; change this value for
  33.                         ; different delay times
  34.  
  35. abs0        segment at 0h
  36.  
  37.         org    4*8h
  38.  
  39. tickint        dd    ?
  40.  
  41. ; interrupt 66h is a user-defined interrupt that is used in conjunction with
  42. ; delay.com to identify it as already being loaded.  other applications
  43. ; may take over the timer interrupt and then this program would not be able to
  44. ; find itself and would make another copy memory resident.
  45.  
  46.         org    4*66h
  47.  
  48. userint        dd    ?
  49.  
  50. abs0        ends
  51.  
  52. code        segment    public 'CODE'
  53.         org    100h
  54.  
  55.         assume    cs:code,ds:code,es:nothing
  56. start:        jmp    delay_init
  57.  
  58. idbyte        db    '@DELAY.COM'        ; identify this as delay.com
  59. oldint        dd    0            ; the original interrupt addr
  60. timer_count    db    0            ; the current number of ticks
  61. delay_amount    db    delay_count        ; the default delay counter
  62.  
  63. delay_int    proc    far
  64.         assume    cs:code,ds:nothing,es:nothing
  65.         push    ax            ; save the registers used
  66.         push    bx
  67.                 inc    timer_count        ; 256 interrupts yet?
  68.         jnz    skip_normal        ; no, delay a while
  69.         pop    bx            ; retore the registers
  70.         pop    ax
  71.         jmp    oldint            ; execute the normal timer int
  72. skip_normal:    mov    bl,[delay_amount]    ; get the delay count
  73. delay_loop:    dec    bl            ; subtract 1
  74.         jnz    delay_loop        ; loop until zero
  75.         mov    al,20h            ; this is the 255 out of 256
  76.         out    20h,al            ; send EOI to interrupt cntrlr
  77.         pop    bx            ; restore those registers and
  78.         pop    ax
  79.         iret                ; return
  80.  
  81. delay_int    endp
  82.  
  83. lastbyte    label    byte            ; last needed byte in resident
  84.                         ; code
  85.  
  86. installed    db    0            ; flag byte for already inst
  87.  
  88.         assume  cs:code,ds:code,es:abs0
  89. delay_init    proc
  90.  
  91. ; first determine if the program is already memory resident
  92.  
  93.         push    ds            ; save ds
  94.         sub    ax,ax            ; ax = 0
  95.         mov    ds,ax            ; ds = ax
  96.         mov    ax,word ptr [ds:19ah]    ; get int 66h current segm
  97.         mov    ds,ax            ; ds = ax
  98.         mov    cx,ax            ; save ax for later
  99.         cmp    byte ptr [ds:103h],'@'  ; is the id byte there?
  100.         jnz    not_inst        ; no, delay not installed yet
  101.         pop    ds            ; restore ds
  102.         mov    [installed],1        ; set installed flag
  103.         jmp    parm_entr        ; see if any parms were entered
  104.  
  105. not_inst:    pop    ds            ; restore ds
  106.         sub    ax,ax            ; ax = 0
  107.         mov    es,ax            ; es = ax
  108.         mov    ax,word ptr tickint    ; get the original int addr
  109.         mov    bx,word ptr tickint+2    ; get the original int segm
  110.         mov    word ptr oldint,ax    ; save the address
  111.         mov    word ptr oldint+2,bx    ; save the segment
  112.         cli                ; no interrupts allowed
  113.         mov    ax,offset delay_int    ; get new int addr
  114.         mov    bx,cs            ; use this segment
  115.         mov    word ptr tickint,ax    ; save the new int addr
  116.         mov    word ptr tickint+2,cs    ; save the new int segm
  117.         mov    word ptr userint,ax    ; save the new int 66h addr
  118.         mov    word ptr userint+2,cs    ; save the new int 66h segm
  119. ;
  120. ; speedup timer chip by 256
  121. ;
  122.         mov    al,00110110b
  123.         out    43h,al
  124.         mov    al,0
  125.         out    40h,al
  126.         mov    al,1
  127.         out    40h,al
  128. ;
  129. ; get the delay off the command line if it was entered.
  130. ; for example to get a delay of 35 counts, type:
  131. ;
  132. ; DELAY <ALT><3><5> <RETURN>
  133. ;
  134. ; this means enter the code 35 by using the ALT key and the numeric keypad
  135. ; note this method doesn't work if prokey is loaded and active.
  136. ;
  137. ; Legal values are from 0 to 255 (0 is the longest delay ==> 256)
  138. ;
  139.  
  140. parm_entr:    cmp    byte ptr [cs:80h],2    ; any parms entered?
  141.         jnz    def_delay        ; no, go ahead and exit
  142.         mov    al,[cs:82h]        ; yes, get the byte
  143.         cmp    [installed],1        ; already installed?
  144.         je    inst_value        ; yes, change resident value
  145.         mov    [delay_amount],al    ; make it the new default
  146.         jmp    def_delay
  147. inst_value:    push    ds            ; save ds
  148.         push    cx            ; push old ds saved in cx
  149.         pop    ds            ; get ds off of stack
  150.         mov    [ds:112h],al        ; move new delay into resident
  151.                         ; delay amount location
  152.         pop    ds            ; restore original ds
  153.  
  154. def_delay:    cmp    [installed],1        ; already installed?
  155.         je    inst_exit        ; exit normally, do not remain
  156.                         ; memory resident
  157.         sti
  158.         mov    dx,offset lastbyte    ; get the ending address
  159.         int    27h            ; exit and stay resident
  160. inst_exit:    int    20h            ; terminate
  161.  
  162. delay_init    endp
  163.  
  164. code        ends
  165.         end    start
  166.